package com.zzg.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zzg.bean.Nanny;
import com.zzg.bean.Page;
import com.zzg.service.NannyService;
import com.zzg.service.impl.NannyServiceImpl;
import org.springframework.context.support.ClassPathXmlApplicationContext;

@WebServlet("/nanny.do")
public class NannyServlet extends BaseServlet{
//	private static final NannyService service =new NannyServiceImpl();
		//分页
		public void selectNannyPage(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException{
			ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
			NannyService service = context.getBean(NannyService.class);

			//获得页数参数
			String pageNo = req.getParameter("pageNo");
			int no = 1;
			if(pageNo != null){
				no = Integer.parseInt(pageNo);
			}
			Page<Nanny> page = service.selectNannyPage(no);
			req.setAttribute("page",page);
			req.getRequestDispatcher("/nanny.jsp").forward(req, resp);
		}
}
